//
//  HomeNoticeCell.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2020/7/27.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "HomeNoticeCell.h"

@interface HomeNoticeCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UIImageView *logoImgView;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UIImageView *arrowImgView;

@end

@implementation HomeNoticeCell

+ (instancetype)HomeNoticeCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"HomeNoticeCell";
    HomeNoticeCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[HomeNoticeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(10, 0, ScreenW - 20, 80)];
        self.bgView.backgroundColor = HexColor(0xffffff);
        self.bgView.layer.masksToBounds = YES;
        self.bgView.layer.cornerRadius = 6;
        [self.contentView addSubview:self.bgView];
        
        self.logoImgView = [[UIImageView alloc] initWithFrame:CGRectMake(19, 22, 36, 36)];
        self.logoImgView.image = [UIImage imageNamed:@"icon_notice"];
        [self.bgView addSubview:self.logoImgView];
        
        self.arrowImgView = [[UIImageView alloc] initWithFrame:CGRectMake(self.bgView.nim_width - 10 - 18, (self.bgView.nim_height - 18) * 0.5, 18, 18)];
        self.arrowImgView.image = [UIImage imageNamed:@"icon_home_arrow"];
        [self.bgView addSubview:self.arrowImgView];
        
        self.titleLab = [[UILabel alloc] initWithFrame:CGRectMake(self.logoImgView.nim_right + 15, 22, self.arrowImgView.nim_left - 15 - (self.logoImgView.nim_right + 15), 36)];
        self.titleLab.textColor = HexColor(0x585974);
        self.titleLab.font = BoldFontOfSize(14);
        self.titleLab.numberOfLines = 2;
        [self.bgView addSubview:self.titleLab];
        
        self.height = self.bgView.nim_bottom;
    }
    return self;
}

-(void)setNoticeText:(NSString *)noticeText {
    _noticeText = noticeText;
    self.titleLab.text = noticeText;
    [self.titleLab sizeToFit];
    self.titleLab.nim_centerY = self.logoImgView.nim_centerY;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
